package cms.jason.web.controller;

import cms.jason.dao.ArticleDao;
import cms.jason.entity.Article;
import cms.jason.entity.Article_;
import com.cn.lotary.base.dao.BaseDao;
import com.cn.lotary.base.web.BaseController;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.persistence.metamodel.SingularAttribute;

/**
 *
 * @author Jason
 */
@ManagedBean
@ViewScoped
public class ArticleController extends BaseController<Article> {

    @EJB
    private ArticleDao articleDao;

    public void persist() {
        if (isNew()) {
            create();
        } else {
            update();
        }
    }

    @Override
    protected BaseDao<Article> dao() {
        return articleDao;
    }

    @Override
    protected SingularAttribute selectItemLabel() {
        return Article_.title;
    }
}
